package com.qiangqiang.task.server.controller;

import com.qiangqiang.task.server.entity.Comments;
import com.qiangqiang.task.server.service.CommentsService;
import com.qiangqiang.task.server.util.ResultVOUtil;
import com.qiangqiang.task.server.vo.ResultVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: task
 * @description:
 * @author: Sky.lin
 * @create: 2018-12-27 16:54
 **/
@RestController
@RequestMapping(value="/comments")
public class CommentsController {
    @Autowired
    CommentsService commentsService;

    @PostMapping("/addComments")
    public ResultVO addComments(Comments comments){
        return ResultVOUtil.success(commentsService.addComments(comments));
    }

    @GetMapping("/showAllComments")
    public ResultVO showAllComments(@Param("page") int page, @Param("pageSize") int pageSize,@Param("postId") long postId){
        return ResultVOUtil.success(commentsService.findAllComments(page,pageSize,postId));
    }
}
